package org.changchen.fgt.controller.admin;

import java.util.List;

import org.changchen.fgt.dto.ApiInfo;
import org.changchen.fgt.dto.ApiResult;
import org.changchen.fgt.service.SourceTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**   
* @ClassName:  SourceController   
* @Description:采集资源管理   
* @author:     ChangChen 
* @date:       2024-03-26 09:19
* @Copyright:  2024 ChangChen. All rights reserved. 
*/
@Controller
@RequestMapping(value = "/admin/source")
public class SourceController {
	
	
	@Autowired
	private SourceTestService sourceTestService;
	
	
	@GetMapping(value = "/list")
	public ModelAndView list() {
		ModelAndView view = new ModelAndView("admin/source");
		List<ApiInfo> sourceList = sourceTestService.sourceList();
		view.addObject("sourceList", sourceList);
		return view;
	}
	

	@PostMapping(value = "/test")
	@ResponseBody
	public ApiResult<Boolean> test(String code){
		return ApiResult.success(sourceTestService.sourceTest(code));
	}
	
	
	@PostMapping(value = "/online")
	@ResponseBody
	public ApiResult<Boolean> online(String code){
		return ApiResult.success(sourceTestService.sourceAdd(code));
	}
	
	
	@PostMapping(value = "/offline")
	@ResponseBody
	public ApiResult<Boolean> offline(String code){
		return ApiResult.success(sourceTestService.sourceDelete(code));
	}
	
}
